﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Collections;
namespace _7._24
{
    class Program
    {
        public static int[] Mus1()
        {
            Console.Write("Введите количество элементов массива: n = ");
            int n = int.Parse(Console.ReadLine());
            int[] arr1 = new int[n];
            for (int i = 0; i < n; i++)
            {
                Console.Write("Введите элемент a[{0}] =  ", i);
                arr1[i] = int.Parse(Console.ReadLine());
            }
            return arr1;
        }
        static ArrayList Count(int[] arr1, int n)
        {
            ArrayList arr2 = new ArrayList();
            if (arr1[0] > arr1[1])
            {
                arr2.Add(arr1[0]);
            }
            for (int i = 0; i < arr1.Length - 2; i++)
            {  
                if ((arr1[i] < arr1[i + 1]) & (arr1[i + 1] > arr1[i + 2]))
                {
                    arr2.Add(arr1[i + 1]);
                }
            }
            if (arr1[arr1.Length - 2] < arr1[arr1.Length - 1])
            {
                arr2.Add(arr1[arr1.Length - 1]);
            }
            return arr2;
        }

        static void Output(ArrayList arr2)
        {
            
                Console.WriteLine("Число локальных максимумов =  " + arr2.Count );
          
        }
        static void Main(string[] args)
        {
            int n = 0;
            int[] arr1 = Mus1();
            ArrayList arr2;
            arr2 = Count(arr1, n);
            Output(arr2);

        }
    }
}